package com.project.controller;

import com.github.pagehelper.PageInfo;
import com.project.bean.CarBean;
import com.project.service.ICarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 汽车控制器
 */
@RestController
@RequestMapping("car")
public class CarController {
    @Autowired
    private ICarService service;

    @RequestMapping("findByItem")
    public PageInfo<CarBean> findByItem(int pageNO,
          Integer startPrice,Integer endPrice,String color){
        return service.findByItem(pageNO,startPrice,endPrice,color);
    }

    @RequestMapping("add")
    public String  add(CarBean car){
        service.add(car);
        return "ok";
    }

    @RequestMapping("del")
    public String del(int id){
        service.del(id);
        return "ok";
    }

    @RequestMapping("findById")
    public CarBean findById(int id){
        return service.findById(id);
    }

    @RequestMapping("update")
    public String update(int id,int price){
        service.update(id,price);
        return "ok";
    }
}
